<?php
                //connect to database
                $link = mysql_connect('localhost', 'pott0180', 'ckersixt');
                if(!$link) {
                        die('Could not connect: ' . mysql_error());
                }

                //select database
                $db_selected = mysql_select_db('soloono_roomFinder', $link);
                if (!$db_selected) {
                        die('Cant use db soloono_roomFinder: ' . mysql_error());
                }


		  //passed in from destination.php
        $buildingName=$_GET['Building'];

		  //select room numbers given building name
        $room_result = sprintf("SELECT Room.room_number FROM Room
                                inner join Building on Room.building_id = Building.id
                                   WHERE Building.name ='$buildingName'");
        $room_query = mysql_query($room_result);

		  //essentially returns room numbers to index.php
        echo "<h4>Room:";
        echo '<select name="Room_to" id="Room_to">';
        while($room_num_array=mysql_fetch_array($room_query))
          {
          echo '<option value="'.$room_num_array["room_number"].'">'.$room_num_array["room_number"].'</option>';
          }
        echo '</select></h4>';


?>
